function form_ajax( container , form , page ) {
    if( typeof form == 'string' ){
    
        $form = $( '#' + form );
        
    }else if( typeof form.load != 'undefined' ){ // to check if the form is already jquery object
        
        $form = form;
        
    } else {
    
       $form = $(form);
    }
    /*url from here*/
    url = $form.attr('action');
    q_string = "";
    
    if(typeof page !='undefined'){
        q_string = (url.indexOf('?')==-1 ? '?' : '&') + 'page=' + page;
    }
    /*type*/
    type = $form.attr('method');
    if(!type){
        type = "POST";/*since it is form the default is post*/
    }
    
    return _post_ajax( container , url + q_string , $form.serialize() , type );
}
function _post_ajax( container , url , data_to_send , type ) {

    p_r = $('#'+container).css('padding-right');
    p_l = $('#'+container).css('padding-left');
    p_t = $('#'+container).css('padding-top');
    p_b = $('#'+container).css('padding-bottom');
    
    w = $('#'+container).width() + parseInt(p_l)+ parseInt(p_r) 
    h = $('#'+container).height() + parseInt(p_b)+ parseInt(p_t)
    l = $('#'+container).offset().left ;
    t = $('#'+container).offset().top;
    
    $loader =   $('<div/>')
                .addClass('loader')
                .css({
                      position:'absolute'
                    ,'top':t+(h/2)-24
                    ,'left':l+(w/2)-71
                    })
                .html( typeof MSG_LOADING != 'undefined' && MSG_LOADING ? MSG_LOADING : 'Loading ...');
    

    $sahder = $('<div/>')
                .css({width:w,height:h,left:l,top:t})
                .addClass('ajax-shader');
    
    
    if(typeof FIX_IE_BUG !='undefined' && $.browser.msie){
        document.location = a_obj.href;
        $('body').append($sahder).append($loader);
        return false;
    }
    
    
    
    if( typeof data_to_send == 'undefined' ){
        data_to_send = [];
    }    
    if( typeof type == 'undefined' ){
        type = 'GET';
    }

    $cont = $( '#' + container );
    $.ajax({
          url: url
        , type: type
        , cache: false
        , data: data_to_send
        , success    : function(data){$cont.html(data);  $sahder.remove();$loader.remove(); }
        , beforeSend : function(data){ $('body').append($sahder).append($loader); }
    });
    
    return false;
}
function link_to_ajax(container , a_obj , form ){
    

    
    if( typeof form != 'undefined' ){
        return form_ajax( container , form , $(a_obj).attr('page') );
    } else {
        return _post_ajax( container , a_obj.href );
    }
    
}
